from datetime import datetime, timedelta
from utils.ioda_spider import IODA_SPIDER
from utils.time_trans import *


def crawl_events(start_time: datetime, end_time: datetime):
    spider = IODA_SPIDER()
    spider.set_config(start_time, end_time)
    spider.run("events")

def crawl_siganl(path:str):
    spider = IODA_SPIDER()
    spider.set_config(None, None)
    spider.load_events_data(path)

if __name__ == "__main__":
    start_time = "2022-02-01 08:00:00"
    end_time = "2024-02-01 08:00:00"

    date_format = "%Y-%m-%d %H:%M:%S"
    start_time = datetime.datetime.strptime(start_time, date_format)
    end_time = datetime.datetime.strptime(end_time, date_format)

    crawl_events(start_time, end_time)
    
    # crawl_siganl("ioda_events_data_seg4.json")

